/**************************************************************************************
*
*	Copyright (C) 2011 Brent Andrew O. Chua - See LICENSE.txt for more info.
*		
*	Filename	-	GUIImage.cpp
*
*	Comments	-	See GUIImage.h
*
**************************************************************************************/

#ifdef __PSX_WINDOWS_WINDOW

#include "../Include/GUIImage.h"
#include "../Include/GraphicsResourceManager.h"

namespace Pulse
{
	GUIImage::GUIImage( const CHAR *pFileName )
		: m_pTexture( PSX_NULL )
	{
		m_fileName = pFileName;
	}
		
	GUIImage::~GUIImage( void )
	{
	
	}

	EErrorCode::Type GUIImage::OnRestore( void )
	{
		if ( m_pTexture ) // Have we already created the texture?
		{
			m_pTexture->DisableResource();
			m_pTexture->RestoreResource();
		}
		else
		{
			m_pTexture = GraphicsResourceManager::GetInstance()->CreateTextureFromFile( m_fileName.GetCString() );

			m_size.x = m_pTexture->GetTextureDescription()->width;
			m_size.y = m_pTexture->GetTextureDescription()->height;

			if ( m_pTexture == PSX_NULL )
				return EErrorCode::GRAPHICS;
		}
		return EErrorCode::NONE;
	}

	EErrorCode::Type GUIImage::OnRender( DOUBLE time, FLOAT dt )
	{
		m_pTexture->Bind();
		return EErrorCode::NONE;
	}

	EErrorCode::Type GUIImage::OnMsgProc( AppMsg msg )
	{

		return EErrorCode::NONE;
	}
}

#endif /* __PSX_WINDOWS_WINDOW */
